package com.web.hawaste.mapper;

import com.web.hawaste.entity.SysResource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author Suzy
 * @since 2022-09-26
 */
public interface SysResourceMapper extends BaseMapper<SysResource> {

    @Select("select distinct sre.* " +
            "from sys_user sus, sys_user_role sur, sys_role sro, " +
            "sys_role_resource srr, sys_resource sre " +
            "where sus.id = #{uid} " +
            "and sus.del_flag = 0 " +
            "and sur.del_flag = 0 " +
            "and sro.del_flag = 0 " +
            "and srr.del_flag = 0 " +
            "and sre.del_flag = 0 " +
            "and sus.id = sur.user_id " +
            "and sur.role_id = sro.id " +
            "and sro.id = srr.role_id " +
            "and srr.resource_id = sre.id")
    List<SysResource> selectByUid(Long uid);
}
